home *** CD-ROM | disk | FTP | other *** search
- /*
- File: StorageClassPublicAPI.h
-
- Contains: This contains the API for all Shim and Storage Class Services
-
- Version: 1.3
-
- Copyright: © 1998-2000 by Apple Computer, Inc., all rights reserved.
-
-
- */
-
- #ifndef __STORAGECLASSPUBLICAPI__
- #define __STORAGECLASSPUBLICAPI__
-
- #include <MacTypes.h>
- #include <USB.h>
-
- // This driver requires USB Manager 1.3 or greater
- #define kMinimumUSBMgrVersion 0x01300000
-
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~ Storage Class API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #define kDispatchTableVersion 0x01000000
-
- // Return codes from the class driver
- enum
- {
- kCommandBusyError = -10000,
- kClassNotConfiguredError,
- kRequestPending = 1
- };
-
- // USB Mass Storage Services Control Call Selectors
- enum
- {
- kUSBStorageControlAbortCommand = 0,
- kUSBStorageControlSetParentsRefNumber = 1
- };
-
- // USB Mass Storage Services Status Call Selectors
- enum
- {
- kUSBStorageStatusGetServicesStatus = 0,
- kUSBStorageStatusGetDeviceStatus,
- kUSBStorageStatusGetRemovalStatus,
- kUSBStorageStatusGetVendorStringPtr,
- kUSBStorageStatusGetProductStringPtr,
- kUSBStorageStatusGetDeviceReleaseNumber
- };
-
- // Return results for the kUSBStorageStatusGetServicesStatus
- // USB Storage Services Status call
- enum
- {
- kUSBStorageServicesNotConfigured = 0,
- kUSBStorageServicesConfigureInProgress,
- kUSBStorageServicesConfigureComplete,
- kUSBStorageServicesConfigureFailed,
- kUSBStorageServicesTerminated
- };
-
- #define kUSBStorageAutoStatusSize 2 // Per the USB CBI Protocol
- #define kUSBStorageMaxCDBSize 12 // Per the USB Mass Storage Class spec.
-
- typedef CALLBACK_API_C( void , StorageClassCompletionProcPtr )(void* storageClassPBPtr );
-
- struct StorageExecuteCommandPB
- {
- UInt8 cdb[kUSBStorageMaxCDBSize]; // -> CDB to send to device
- UInt32 flags; // -> Data transfer flags (See below)
- Ptr userBuffer; // -> Pointer to user buffer
- StorageClassCompletionProcPtr completionProc; // -> Completion routine
- UInt32 timeout; // -> Number of milliseconds until the command timesout
- UInt32 expectedCount; // -> Expected number of bytes to transfer
- UInt32 actualCount; // <- Actual number of bytes transferred
- OSStatus status; // <- Result of operation
- UInt8 autoStatus[kUSBStorageAutoStatusSize]; // <- Device status
- Boolean autoStatusIsValid; // <- true indicates that the data in autoStatus is valid
- UInt16 reserved1; // Used for padding
- };
- typedef struct StorageExecuteCommandPB StorageExecuteCommandPB;
- typedef StorageExecuteCommandPB * StorageExecuteCommandPBPtr;
-
- // Data transfer flags for StorageExecuteCommandPB
- enum
- {
- kStorageDataIn = 0x0001,
- kStorageDataOut = 0x0002,
- kStorageNoData = 0x0004,
- kStorageSGBuffer = 0x0010,
- kStorageUseCommandCompletionInt = 0x0100
- };
-
- // Structures for Scatter-Gather list suppport
- // Read/Write a scatter-gather list entry point
- struct USBSGElement {
- Ptr SGAddr;
- UInt32 SGCount;
- };
- typedef struct USBSGElement USBSGElement, *USBSGElementPtr;
-
- struct USBSGList
- {
- UInt32 sgNumberElements;
- USBSGElementPtr sgElementList;
- };
-
- typedef struct USBSGList USBSGList, *USBSGListPtr;
-
- typedef CALLBACK_API_C( OSStatus , StorageInitializeProcPtr )(void);
- typedef CALLBACK_API_C( OSStatus , StorageTerminateProcPtr )(void);
- typedef CALLBACK_API_C( OSStatus , StorageControlProcPtr )(UInt32 theControlSelector, void *theControlData);
- typedef CALLBACK_API_C( OSStatus , StorageStatusProcPtr )(UInt32 theInfoSelector, void *theInfo);
- typedef CALLBACK_API_C( OSStatus , StorageExecuteCommandProcPtr )( StorageExecuteCommandPBPtr storageExecuteCommandPBPtr );
-
- struct StorageClassDispatchTable
- {
- UInt32 dispatchTableVersion;
- StorageInitializeProcPtr pStorageInitialize;
- StorageTerminateProcPtr pStorageTerminate;
- StorageControlProcPtr pStorageControl;
- StorageStatusProcPtr pStorageStatus;
- StorageExecuteCommandProcPtr pStorageExecuteCmd;
- };
- typedef struct StorageClassDispatchTable StorageClassDispatchTable;
- typedef StorageClassDispatchTable * StorageClassDispatchTablePtr;
-
- extern StorageClassDispatchTable TheStorageClassDispatchTable;
-
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~ Shim API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // The control calls the Shim makes to the Unit Table driver
- // to set the information from the Storage Class
- enum
- {
- kInitializeDeviceAccess = 500,
- kTerminateDeviceAccess = 501
- };
-
- enum
- {
- kUSBStorageEventRemoveManualEjectMedia = 1,
- kUSBStorageEventManualEjectMediaWasRemoved,
- kUSBStorageEventDeviceWasRemoved,
- kUSBStorageEventUnusableMediaEjected
- };
-
-
- // Enumerations for Mass Storage Class Subclass types
- enum
- {
- kUSBStorageRBCSubclass = 1,
- kUSBStorageSFF8020iSubclass = 2,
- kUSBStorageQIC157Subclass = 3,
- kUSBStorageUFISubclass = 4,
- kUSBStorageSFF8070iSubclass = 5,
- kUSBStorageSCSITransparentSubclass = 6
- };
-
- typedef CALLBACK_API_C( OSStatus , StandardDialogProcPtr )( DriverRefNum drvrRefNum, UInt16 messageNumber );
-
- #define kCurrentUSBStorageClassDispatchTableVersion 0x00000001
-
- struct StorageClassShimDispatchTable
- {
- StandardDialogProcPtr DisplayDialog;
- StandardDialogProcPtr RemoveDialog;
- };
-
- typedef struct StorageClassShimDispatchTable StorageClassShimDispatchTable;
- typedef StorageClassShimDispatchTable * StorageClassShimDispatchTablePtr;
-
- struct USBStorageClassSetupTable
- {
- UInt32 dispatchTableVersion;
- USBDeviceRef usbDeviceRef;
- USBDeviceRef usbParentRef;
- UInt8 usbSubClass;
- UInt16 usbVendor;
- UInt16 usbProduct;
- StorageClassShimDispatchTablePtr shimDispatchTable;
- StorageClassDispatchTablePtr theStorageClassDispatchTable;
- };
-
- typedef struct USBStorageClassSetupTable USBStorageClassSetupTable;
- typedef USBStorageClassSetupTable * USBStorageClassSetupTablePtr;
-
- #endif